﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace NinjaToolbox.PhysicsSystem
{
    public class BVHTreeTest2 : MonoBehaviour
    {
        public BVHTreeContainer container;
        public BoxCollider boundsBoxCollider;

        PhysicsBase[] mRefPhysicsBaseArray;


        void OnDrawGizmos()
        {
            if (container.Tree == null) return;

            if (mRefPhysicsBaseArray == null)
                mRefPhysicsBaseArray = new PhysicsBase[10];

            var count = container.Tree.Intersect(boundsBoxCollider.bounds, mRefPhysicsBaseArray);
            for (int i = 0; i < count; i++)
            {
                var bounds = mRefPhysicsBaseArray[i].PhysicsShape.Bounds;
                Gizmos.DrawWireCube(bounds.center, bounds.size);
            }
        }
    }
}
